package com.dunqi.gpm.shunqing.home.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import com.dunqi.gpm.shunqing.R;
import com.dunqi.gpm.shunqing.common.base.BaseAct;
import com.dunqi.gpm.shunqing.common.util.TimeUtil;
import com.dunqi.gpm.shunqing.common.view.ComTitleBar;
import com.dunqi.gpm.shunqing.home.bean.Compared;
import com.dunqi.gpm.shunqing.home.bean.Problem;
import com.dunqi.gpm.shunqing.home.widget.NormalView;

import java.util.ArrayList;

import butterknife.BindView;

public class ProblemConsortDetailActivity extends BaseAct {

    private static final String DATA = "data";
    @BindView(R.id.title_bar)
    ComTitleBar titleBar;
    @BindView(R.id.problem_audit_type_view)
    NormalView problemAuditTypeView;
    @BindView(R.id.problem_type_view)
    NormalView problemTypeView;
    @BindView(R.id.report_time_view)
    NormalView reportTimeView;
    @BindView(R.id.progress_type_view)
    NormalView progressTypeView;
    @BindView(R.id.attach_branch_view)
    NormalView attachBranchView;
    @BindView(R.id.reporter_name_view)
    NormalView reporterNameView;
    @BindView(R.id.reporter_branch_view)
    NormalView reporterBranchView;
    @BindView(R.id.problem_des_view)
    NormalView problemDesView;
    @BindView(R.id.problem_suggest_view)
    NormalView problemSuggestView;

    Problem item;

    ArrayList<Compared> problemStatuss = new ArrayList<>();
    ArrayList<Compared> progressTypes = new ArrayList<>();

    @Override
    protected void refreshData(Bundle savedInstanceState) {

    }

    @Override
    protected void initUiAndListener() {
        item = (Problem) getIntent().getSerializableExtra(DATA);

        initData();

        int problemStatus = item.getProblemStatus();
        Compared compared = problemStatuss.get(problemStatus - 1);
        problemAuditTypeView.setText(compared.getDes());

        problemTypeView.setText(item.getProblemType());

        String reportTime = item.getReportTime();
        reportTimeView.setText(TimeUtil.getTen(reportTime));

        int progressType = item.getProgressType();
        String des = progressTypes.get(progressType).getDes();
        progressTypeView.setText(des);

        attachBranchView.setText(item.getInvolveDepartment());

        reporterNameView.setText(item.getReporterName());

        reporterBranchView.setText(item.getReporterOrgName());

        problemDesView.setText(item.getProblemDesc());

        problemSuggestView.setText(item.getMeasuresSuggestion());


    }

    private void initData() {
        problemStatuss.add(new Compared(1, "未处理"));
        problemStatuss.add(new Compared(2, "已收集"));
        problemStatuss.add(new Compared(3, "协调中"));
        problemStatuss.add(new Compared(4, "已解决"));
        problemStatuss.add(new Compared(5, "不能解决"));
        problemStatuss.add(new Compared(6, "关闭"));

        progressTypes.add(new Compared(0, "未填写"));
        progressTypes.add(new Compared(1, "进展顺利"));
        progressTypes.add(new Compared(2, "基本正常"));
        progressTypes.add(new Compared(3, "进度滞后"));
        progressTypes.add(new Compared(4, "申请结项"));
    }


    public static void start(Context context, Problem item) {
        Intent intent = new Intent(context, ProblemConsortDetailActivity.class);
        intent.putExtra(DATA, item);
        context.startActivity(intent);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_problem_consort_detail;
    }
}
